package org.hako.recite.word.parser;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.hako.recite.word.model.Word;

/**
 * Word list, contains column titles and words.
 * 
 * @since 0.4.9
 * @author <a href="mailto:xnnyygn@gmail.com">xnnyygn</a>
 */
public class WordList implements Iterable<Word> {

	private String[] columnTitles;
	private List<Word> words;

	/**
	 * Create
	 */
	public WordList() {
		super();
		words = new ArrayList<Word>();
	}

	/**
	 * Set columnTitles.
	 * 
	 * @param columnTitles
	 *            the columnTitles to set
	 */
	public void setColumnTitles(String[] columnTitles) {
		this.columnTitles = columnTitles;
	}

	/**
	 * Get columnTitles.
	 * 
	 * @return the columnTitles
	 */
	public String[] getColumnTitles() {
		return columnTitles;
	}

	/**
	 * Get column count.
	 * 
	 * @return
	 * @see #getColumnTitles()
	 */
	public int getColumnCount() {
		return getColumnTitles().length;
	}

	/**
	 * Get word.
	 * 
	 * @param index
	 * @return
	 */
	public Word getWord(int index) {
		return words.get(index);
	}

	/**
	 * Get words.
	 * 
	 * @return the words
	 */
	public List<Word> getWords() {
		return words;
	}

	/**
	 * Get word count.
	 * 
	 * @return
	 */
	public int getWordCount() {
		return words.size();
	}

	/**
	 * Add word.
	 * 
	 * @param word
	 */
	public void addWord(Word word) {
		words.add(word);
	}

	@Override
	public Iterator<Word> iterator() {
		return words.iterator();
	}

}
